#include <stdio.h>
#include <stdlib.h>

int strlen1(const char *);
int strlen2(const char[]);

void main()
{
    char array[46] = "How are you? Fine,and you? See you tomorrow !";
    char *p = "Goodbye!";
    char *pt = &array[35];
    printf("%d\t", strlen1(array));
    printf("%d\t", strlen1("hello, word"));
    printf("%d\n", strlen1(p));
    printf("%d\t", strlen2(array));
    printf("%d\t", strlen2("hello, word"));
    printf("%d\n", strlen2(p));
    printf("%d\t%d\n", strlen1(pt), strlen2(pt));
    printf("%d\t%s\n", strlen1(&array[35]), &array[35]);
    printf("%d\t%s\n", strlen2(&array[35]), &array[35]);
}

int strlen1(const char *s)
{
    int n;
    for (n = 0; *s != '\0'; s++)
        n++;
    return n;
}

int strlen2(const char s[])
{
    int n;
    for (n = 0; *s != '\0'; s++)
        n++;
    return n;
}

/*
使用const限定符不影响通过指向子数组的方法把数组的一部分作为参数传递给函数。
例如，a是一个数组，“&a[2]”和“（a+2）”都是把起始于a[2]的子数组的地址作为参数。

*/